package com.ruitu.mall_98_seller.dao.http;


import com.ruitu.arad.api.BaseResult;
import com.ruitu.arad.api.PageModel;
import com.ruitu.mall_98_seller.dao.bean.AfterSale;
import com.ruitu.mall_98_seller.dao.bean.Book;
import com.ruitu.mall_98_seller.dao.bean.Express;
import com.ruitu.mall_98_seller.dao.bean.Msg;
import com.ruitu.mall_98_seller.dao.bean.Order;
import com.ruitu.router_module.bean.RongToken;
import com.ruitu.router_module.bean.RongUser;
import com.ruitu.router_module.bean.User;
import com.ruitu.router_module.bean.Version;

import java.util.List;

import io.reactivex.Observable;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.POST;
import retrofit2.http.Query;
import retrofit2.http.Streaming;
import retrofit2.http.Url;

public interface ApiService {
    //融云获取token接口
    @FormUrlEncoded
    @POST("getToken.json")
    Observable<RongToken> reqRongToken(
            @Header("App-Key") String appKey,
            @Header("Nonce") String Nonce,
            @Header("Timestamp") String Timestamp,
            @Header("Signature") String Signature,
            @Field("userId") String userId,
            @Field("name") String name,
            @Field("portraitUri") String portraitUri);

    // chat/getUserInfo 获取用户信息
    @GET("chat/getUserInfo")
    Observable<BaseResult<RongUser>> reqUserInfo(@Query("accountId") String accountId);

//    // index/appIndex app首页
//    @GET("index/appIndex")
//    Observable<BaseResult<HomeData>> reqAppHome(@Query("cityName") String cityName, @Query("accountId") String accountId);

    // cart/addCart 加入购物车
    @FormUrlEncoded
    @POST("cart/addCart")
    Observable<BaseResult> addToCart(@Field("goodsId") String goodsId, @Field("accountId")
            String accountId, @Field("num") int num, @Field("skuId") String skuId);

    // version/checkOne  检查新版本  参数 @Query()
    @GET("version/checkOne")
    Observable<BaseResult<Version>> reqNewVersion();

    // 卖家端登录
    @GET("buyerSide/login")
    Observable<BaseResult<User>> login(@Query("userName") String uName, @Query("password") String pwd);

    // 卖家获取订单列表 orderStatus 和 orderStatus 为可选参数,用于筛选订单状态
    @GET("buyerSide/getAllOrder")
    Observable<BaseResult<PageModel<Order>>> reqOrderList(@Query("companyId") String comId
            , @Query("size") int size, @Query("page") int page
            , @Query("orderStatus") String status, @Query("orderType") String type);

    // buyerSide/orderDetails 订单详情
    @GET("buyerSide/orderDetails")
    Observable<BaseResult<Order>> reqOrderDetail(@Query("orderId") String oId);

    // buyerSide/sendMsg 通知用户支付尾款  orderId 小订单id  信息类型 1 支付定金 2 支付尾款
    @GET("buyerSide/sendMsg")
    Observable<BaseResult> sendMsg(@Query("orderId") String oId, @Query("type") String type);

    // buyerSide/expressMesList 获取快递公司信息
    @GET("buyerSide/expressMesList")
    Observable<BaseResult<List<Express>>> expressMesList();

    // buyerSide/deliverGoods 卖家端发货 orderId 小订单id  logistics 快递编号(快递信息中的code) logisticsNum 快递单号
    @FormUrlEncoded
    @POST("buyerSide/deliverGoods")
    Observable<BaseResult> deliverGoods(@Field("orderId") String oId
            , @Field("logistics") String logCode, @Field("logisticsNum") String logNum);

    // buyerSide/afterSaleMsg 售后详情  orderId 小订单id
    @GET("buyerSide/afterSaleMsg")
    Observable<BaseResult<AfterSale>> afterSaleDetail(@Query("orderId") String oId);

    // buyerSide/refundApprove 售后审批  status 0 同意 1 拒绝
    @FormUrlEncoded
    @POST("buyerSide/refundApprove")
    Observable<BaseResult> refundApprove(@Field("orderId") String oId, @Field("status") String status);

    // buyerSide/systemMsg 消息列表
    @GET("buyerSide/systemMsg")
    Observable<BaseResult<PageModel<Msg>>> reqMsgList(@Query("companyId") String comId
            , @Query("size") int size, @Query("page") int page);

    // buyerSide/allReadByCompany 标记消息全部已读
    @GET("buyerSide/allReadByCompany")
    Observable<BaseResult> reqAllReadMsg(@Query("companyId") String comId);

    // buyerSide/getUnreadMsg 获取未读消息数量
    @GET("buyerSide/getUnreadMsg")
    Observable<BaseResult<String>> reqUnReadMsgNum(@Query("companyId") String comId);

    // buyerSide/readMsg  消息详情
    @GET("buyerSide/readMsg")
    Observable<BaseResult<Msg>> reqMsgDetail(@Query("id") String msgId);

    // buyerSide/goodsReserverList 预订单列表
    @GET("buyerSide/goodsReserverList")
    Observable<BaseResult<PageModel<Book>>> reqBookList(@Query("companyId") String comId
            , @Query("size") int size, @Query("page") int page, @Query("status") String status);

    // buyerSide/getReserveDetail 预订单详情
    @GET("buyerSide/getReserveDetail")
    Observable<BaseResult<Book>> reqBookDetail(@Query("id") String bookId);

    // buyerSide/refuseReserve 拒绝预订单
    @FormUrlEncoded
    @POST("buyerSide/refuseReserve")
    Observable<BaseResult> reqDenyBook(@Field("id") String id);

    // buyerSide/agreeReserve  同意预订单
    @FormUrlEncoded
    @POST("buyerSide/agreeReserve")
    Observable<BaseResult> reqAgreeBook(@Field("id") String id, @Field("advanceRatio") String preRatio
            , @Field("deliveryTime") String sendTime, @Field("goodsPrice") String proPrice);

    // buyerSide/countMsg 首页统计信息
    @GET("buyerSide/countMsg")
    Observable<BaseResult> reqHomeNums(@Query("companyId") String comId);

    // buyerSide/version/checkOne 获取新版本 1 买家端 2 卖家端
    @GET("buyerSide/version/checkOne")
    Observable<BaseResult<Version>> reqNewVersion(@Query("type") String type);

    @Streaming
    @GET
    Observable<ResponseBody> downloadApk(@Url String url);

    // retrofit
    @Streaming
    @GET
    Call<ResponseBody> download(@Url String url);
}